package exam.wzb.jsp.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class AppConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginIntercept())
                .addPathPatterns("/**")
                .excludePathPatterns("/css/**")
                .excludePathPatterns("/editor.md/**")
                .excludePathPatterns("/img/**")
                .excludePathPatterns("/js/**")
                .excludePathPatterns("/login.html")
                .excludePathPatterns("/reg.html")
                .excludePathPatterns("/blog_list.html")//列表页不拦
                .excludePathPatterns("/blog_content.html")//文章详情页不拦
                .excludePathPatterns("/art/detail")//列表页查看详情页的途径不拦（得到文章作者id）
                .excludePathPatterns("/art/increment-rcount")//增加阅读量代码不拦截
                .excludePathPatterns("/art/listbypage")//文章主页不拦
                .excludePathPatterns("/user/getuserbyid")
                .excludePathPatterns("/user/login")//登录接口不拦
                .excludePathPatterns("/user/reg");//注册接口不拦

    }
}
